package com.yz.platform.common.exception;

/**
 * 任务相关异常 author:lin Date : 2017/9/1 下午2:51
 */
public class TaskException extends RuntimeException {


    private static final long serialVersionUID = 1870835486798448798L;

    private String taskId;

    private String errorMessage;

    private String errorCode;


    public TaskException() {
    }

    public TaskException(String errorMessage) {
        this(errorMessage, (Throwable) null);
    }

    public TaskException(Throwable cause) {
        this((String) null, cause);
    }

    public TaskException(String errorMessage, Throwable cause) {
        super((String) null, cause);
        this.errorMessage = errorMessage;
        this.errorCode = "Unknown";
        this.taskId = "Unknown";
    }

    public TaskException(String errorMessage, String errorCode, String requestId) {
        this(errorMessage, errorCode, requestId, (Throwable) null);
    }

    public TaskException(String errorMessage, String errorCode, String requestId, Throwable cause) {
        this(errorMessage, cause);
        this.errorCode = errorCode;
        this.taskId = requestId;
    }

    public String getErrorMessage() {
        return this.errorMessage;
    }

    public String getErrorCode() {
        return this.errorCode;
    }

    public String getRequestId() {
        return this.taskId;
    }

    public String getMessage() {
        return this.getErrorMessage() + "\n[ErrorCode]: " + this.errorCode != null ? this.errorCode : ("\n[taskId]: " + this.taskId != null ? this.taskId : "");
    }
}
